import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);


// 全局路由
export const globalRoutes = [

	// 登录
	{
		path: '/login',
		component: () => import('@/views/login')
	},

	// 注册
	{
		path: '/register',
		component: () => import('@/views/register')
	},

	// 忘记密码
	{
		path: '/forgetPwd',
		component: () => import('@/views/forgetPwd')
	},
	
	// 申请
	{
		path: '/apply',
		component: () => import('@/views/apply')
	},
	
	// 商品列表
	{
		path: '/goodList',
		component: () => import('@/views/goodList')
	},
	
	// 商品详情
	{
		path: '/goodDetail/:goodId',
		component: () => import('@/views/seckillGood')
	},
	
	// 支付页面
	{
		path: '/payOrder/:orderId',
		component: () => import('@/views/payOrder')
	},
	
	// 订单列表
	{
		path: '/orderList',
		component: () => import('@/views/orderList')
	}

]

// 防止连续点击多次路由报错
let routerPath = Router.prototype.push;
Router.prototype.push = function push(location) {
	return routerPath.call(this, location).catch(err => err)
}

export default new Router({
	mode: 'history', // 去掉url中的#
	routes: globalRoutes,
	base: process.env.BASE_URL
});
